package com.bocai.yuweiwangluo.activity;


import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import com.bocai.yuweiwangluo.R;
import com.bocai.yuweiwangluo.base.BaseActivity;
import com.bocai.yuweiwangluo.presenter.BindingPhonePresenter;
import com.bocai.yuweiwangluo.viewModel.IBindingPhoneView;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;

/**
 * 绑定新号码界面
 */
public class BindingNewPhoneActivity extends BaseActivity implements View.OnClickListener,IBindingPhoneView {
    @ViewInject(R.id.et_binding_phone)
    EditText etPhone;
    @ViewInject(R.id.btn_binding_getcode)
    Button btnGetCode;
    @ViewInject(R.id.et_binding_code)
    EditText etCode;
    @ViewInject(R.id.btn_binding)
    Button btnBinding;
    private BindingPhonePresenter bindingPhonePresenter;
    @Override
    protected int contentView()
    {
        return R.layout.activity_binding_newphone;
    }

    @Override
    protected void setData()
    {
        ViewUtils.inject(this);
        initToolbar("绑定新号码");
        initEvent();
        getBindingPhonePresenter();
    }

    @Override
    protected void initEvent() {
        btnGetCode.setOnClickListener(this);
        btnBinding.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.btn_binding_getcode:
                //获取验证码
                bindingPhonePresenter.getCode();
                break;
            case R.id.btn_binding:
                bindingPhonePresenter.verificationCode();
               // 提交
                break;
        }
    }

    @Override
    public String getTel() {
        return etPhone.getText().toString();
    }

    @Override
    public String getCode() {
        return etCode.getText().toString();
    }

    @Override
    public void finishActivity() {
        finish();
    }

    @Override
    public BindingPhonePresenter getBindingPhonePresenter() {
        bindingPhonePresenter=new BindingPhonePresenter(this,this,btnGetCode,this);
        return bindingPhonePresenter;
    }

}
